package com.itheima.mapper.backend;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * 预约设置持久层
 */
@Mapper
public interface OrdersettingMapper {

    /**
     * 根据月份查询预约设置数据
     * @param firstDayOfMonth
     * @param lastDayOfMonth
     * @return
     */
    @Select("select * from t_ordersetting where orderDate >= #{firstDayOfMonth} and orderDate <= #{lastDayOfMonth}")
    List<OrderSetting> getOrderSettingByMonth(Date firstDayOfMonth, Date lastDayOfMonth);

    /**
     * 根据日期查询预约设置数据
     * @param orderDate
     * @return
     */
    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting findByOrderDate(Date orderDate);

    /**
     * 根据日期设置每天可预约人数
     * @param orderDate
     * @param number
     */
    @Insert("insert into t_ordersetting (orderDate,number) values (#{orderDate},#{number})")
    void addNumberByOrderDate(Date orderDate,Integer number);

    /**
     * 根据日期修改每天可预约人数
     * @param orderDate
     * @param number
     */
    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    void editByOrderDate(Date orderDate,Integer number);
}
